package com.lms.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-06-16 13:49
 * @Description:
 */
public class NettyHttpServerInitializer  extends ChannelInitializer<SocketChannel> {


    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //向管道加入处理器
        ChannelPipeline pipeline = socketChannel.pipeline();
        //HttpServerCodec是netty提供的处理http的编解码器
        pipeline.addLast("serverCodec",new HttpServerCodec());
        //添加自定义的处理器
        pipeline.addLast("MyServerHandler",new NettyHttpServerHandler());
    }
}
